package com.cdzy.service.impl;

import com.cdzy.mapper.BookTypesMapper;
import com.cdzy.pojo.BookTypes;
import com.cdzy.service.BookTypesService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

/**
 * 图书分类表(BookTypes)表服务实现类
 *
 * @author makejava
 * @since 2025-04-01 10:04:21
 */
@Service("bookTypesService")
public class BookTypesServiceImpl implements BookTypesService {
    @Resource
    private BookTypesMapper bookTypesMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param bookTypeId 主键
     * @return 实例对象
     */
    @Override
    public BookTypes queryById(Integer bookTypeId) {
        return this.bookTypesMapper.queryById(bookTypeId);
    }


    /**
     * 新增数据
     *
     * @param bookTypes 实例对象
     * @return 实例对象
     */
    @Override
    public BookTypes insert(BookTypes bookTypes) {
        this.bookTypesMapper.insert(bookTypes);
        return bookTypes;
    }

    /**
     * 修改数据
     *
     * @param bookTypes 实例对象
     * @return 实例对象
     */
    @Override
    public BookTypes update(BookTypes bookTypes) {
        this.bookTypesMapper.update(bookTypes);
        return this.queryById(bookTypes.getBookTypeId());
    }

    /**
     * 通过主键删除数据
     *
     * @param bookTypeId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer bookTypeId) {
        return this.bookTypesMapper.deleteById(bookTypeId) > 0;
    }

}
